package logic

import (
	"context"
	"srv/house"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseStatusLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewHouseStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseStatusLogic {
	return &HouseStatusLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *HouseStatusLogic) HouseStatus(req *types.HouseStatusRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	userId := l.ctx.Value("userId").(uint)
	status, err := l.svcCtx.HouseSrv.HouseStatus(l.ctx, &house.HouseStatusRequest{
		UserId:  int64(userId),
		HouseId: int64(req.HouseId),
		Status:  int64(req.Status),
	})
	if err != nil {
		return &types.Response{
			Code: 500,
			Msg:  err.Error(),
			Data: nil,
		}, nil
	}
	return &types.Response{
		Code: 200,
		Msg:  "审核成功",
		Data: map[string]interface{}{
			"status": status,
		},
	}, nil
}
